{"action":"created","comment":{"url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/comments/98525855","pull_request_review_id":19170142,"id":98525855,"diff_hunk":"@@ -0,0 +1,105 @@\n+/**\n+ * @license\n+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n+ * This code may only be used under the BSD style license found at\n+ * http://polymer.github.io/LICENSE.txt\n+ * The complete set of authors may be found at\n+ * http://polymer.github.io/AUTHORS.txt\n+ * The complete set of contributors may be found at\n+ * http://polymer.github.io/CONTRIBUTORS.txt\n+ * Code distributed by Google as part of the polymer project is also\n+ * subject to an additional IP rights grant found at\n+ * http://polymer.github.io/PATENTS.txt\n+ */\n+\n+import {assert} from 'chai';\n+import * as ts from 'typescript';\n+\n+import {AnalysisContext} from '../../core/analysis-context';\n+import {TypeScriptAnalyzer} from '../../typescript/typescript-analyzer';\n+import {UrlLoader} from '../../url-loader/url-loader';\n+import {UrlResolver} from '../../url-loader/url-resolver';\n+\n+class TestUrlResolver implements UrlResolver {\n+  canResolve(url: string) {\n+    return url === '/typescript/test.ts';\n+  }\n+\n+  resolve(url: string) {\n+    return url;\n+  }\n+}\n+\n+class TestUrlLoader implements UrlLoader {\n+  canLoad(url: string) {\n+    return url === '/typescript/test.ts';\n+  }\n+\n+  load(url: string): Promise<string> {\n+    if (url === '/typescript/test.ts') {\n+      return Promise.resolve(`\n+class A extends HTMLElement {\n+  foo() { return 'bar'; }\n+}\n+`);\n+    } else {\n+      throw new Error(`cannot load file ${url}`);\n+    }\n+  }\n+}\n+\n+suite('TypeScriptParser', () => {\n+  let typescriptAnalyzer: TypeScriptAnalyzer;\n+  let analysisContext: AnalysisContext;\n+\n+  setup(() => {\n+    const urlLoader = new TestUrlLoader();\n+    const urlResolver = new TestUrlResolver();\n+    analysisContext = new AnalysisContext({urlLoader, urlResolver});\n+    typescriptAnalyzer = new TypeScriptAnalyzer(analysisContext);\n+  });\n+\n+  suite('parse()', () => {\n+\n+    test('parses classes', async() => {\n+      const fileName = '/typescript/test.ts';\n+      // This puts a document into the scanned document cache\n+      await analysisContext.scan(fileName);\n+      const program = typescriptAnalyzer.analyze(fileName);\n+      const checker = program.getTypeChecker();\n+\n+      assert.deepEqual(program.getRootFileNames(), [fileName]);\n+\n+      // Get the HTMLElement type from the DOM module\n+      let htmlElement: ts.Type;\n+      const domSource = program.getSourceFile('/$lib/DOM.d.ts');\n+      ts.forEachChild(domSource, (node) => {\n+        if (node.kind === ts.SyntaxKind.InterfaceDeclaration) {\n+          const innerface = node as ts.InterfaceDeclaration;\n+          if (innerface.name.getText() === 'HTMLElement') {\n+            htmlElement = checker.getTypeAtLocation(innerface);\n+          }\n+        }\n+      });\n+\n+      // Get class A and assert that it extends HTMLElement\n+      const sourceFile = program.getSourceFile(fileName);\n+      ts.forEachChild(sourceFile, (node) => {\n+        if (node.kind === ts.SyntaxKind.ClassDeclaration) {\n+          const clazz = node as ts.ClassDeclaration;\n+          if (clazz.name && clazz.name.getText() === 'A') {\n+            const type = checker.getTypeAtLocation(clazz);\n+            const baseTypes = checker.getBaseTypes(type as ts.InterfaceType);","path":"src/test/typescript/typescript-analyzer_test.ts","position":92,"original_position":92,"commit_id":"5203a37fa58b70e0ee7edc2208d244a3f6f1ec5a","original_commit_id":"5203a37fa58b70e0ee7edc2208d244a3f6f1ec5a","user":{"login":"rictic","id":1659,"avatar_url":"https://avatars.githubusercontent.com/u/1659?v=3","gravatar_id":"","url":"https://api.github.com/users/rictic","html_url":"https://github.com/rictic","followers_url":"https://api.github.com/users/rictic/followers","following_url":"https://api.github.com/users/rictic/following{/other_user}","gists_url":"https://api.github.com/users/rictic/gists{/gist_id}","starred_url":"https://api.github.com/users/rictic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rictic/subscriptions","organizations_url":"https://api.github.com/users/rictic/orgs","repos_url":"https://api.github.com/users/rictic/repos","events_url":"https://api.github.com/users/rictic/events{/privacy}","received_events_url":"https://api.github.com/users/rictic/received_events","type":"User","site_admin":false},"body":"Well there's the cast to ClassDecoration that immediately follows a comparison for same, which is just a discrepancy in the type checker (can't do type discrimination on enum instances).\r\n\r\nThe type type should be able to do the same (even if we might not bother with the assertion here).","created_at":"2017-01-30T19:52:18Z","updated_at":"2017-01-30T19:52:18Z","html_url":"https://github.com/Polymer/polymer-analyzer/pull/437#discussion_r98525855","pull_request_url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437","_links":{"self":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/comments/98525855"},"html":{"href":"https://github.com/Polymer/polymer-analyzer/pull/437#discussion_r98525855"},"pull_request":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437"}}},"pull_request":{"url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437","id":103683536,"html_url":"https://github.com/Polymer/polymer-analyzer/pull/437","diff_url":"https://github.com/Polymer/polymer-analyzer/pull/437.diff","patch_url":"https://github.com/Polymer/polymer-analyzer/pull/437.patch","issue_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/437","number":437,"state":"open","locked":false,"title":"Typescript 1.1","user":{"login":"justinfagnani","id":522948,"avatar_url":"https://avatars.githubusercontent.com/u/522948?v=3","gravatar_id":"","url":"https://api.github.com/users/justinfagnani","html_url":"https://github.com/justinfagnani","followers_url":"https://api.github.com/users/justinfagnani/followers","following_url":"https://api.github.com/users/justinfagnani/following{/other_user}","gists_url":"https://api.github.com/users/justinfagnani/gists{/gist_id}","starred_url":"https://api.github.com/users/justinfagnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinfagnani/subscriptions","organizations_url":"https://api.github.com/users/justinfagnani/orgs","repos_url":"https://api.github.com/users/justinfagnani/repos","events_url":"https://api.github.com/users/justinfagnani/events{/privacy}","received_events_url":"https://api.github.com/users/justinfagnani/received_events","type":"User","site_admin":false},"body":"<!--\r\n  Thanks for the PR!\r\n\r\n  If this change has a user visible change (including\r\n  bug fixes, new features, etc) please describe the change in\r\n  CHANGELOG.md.\r\n\r\n  If the change is an entirely package-internal reshuffling/refactoring\r\n  should the change not be described in the CHANGELOG.\r\n\r\n  Consider also updating the README.\r\n\r\n  More info: http://keepachangelog.com/en/0.3.0/\r\n -->\r\n\r\n - [ ] CHANGELOG.md has been updated\r\n","created_at":"2017-01-30T06:10:01Z","updated_at":"2017-01-30T19:52:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"829ab27fb76352d6ab50e05d7b5b63baaf82776c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437/commits","review_comments_url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437/comments","review_comment_url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/437/comments","statuses_url":"https://api.github.com/repos/Polymer/polymer-analyzer/statuses/5203a37fa58b70e0ee7edc2208d244a3f6f1ec5a","head":{"label":"Polymer:typescript-1.1","ref":"typescript-1.1","sha":"5203a37fa58b70e0ee7edc2208d244a3f6f1ec5a","user":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":30035812,"name":"polymer-analyzer","full_name":"Polymer/polymer-analyzer","owner":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polymer/polymer-analyzer","description":"A static analysis framework for web applications.","fork":false,"url":"https://api.github.com/repos/Polymer/polymer-analyzer","forks_url":"https://api.github.com/repos/Polymer/polymer-analyzer/forks","keys_url":"https://api.github.com/repos/Polymer/polymer-analyzer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/polymer-analyzer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/polymer-analyzer/teams","hooks_url":"https://api.github.com/repos/Polymer/polymer-analyzer/hooks","issue_events_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/polymer-analyzer/events","assignees_url":"https://api.github.com/repos/Polymer/polymer-analyzer/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/polymer-analyzer/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/polymer-analyzer/tags","blobs_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/polymer-analyzer/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/polymer-analyzer/languages","stargazers_url":"https://api.github.com/repos/Polymer/polymer-analyzer/stargazers","contributors_url":"https://api.github.com/repos/Polymer/polymer-analyzer/contributors","subscribers_url":"https://api.github.com/repos/Polymer/polymer-analyzer/subscribers","subscription_url":"https://api.github.com/repos/Polymer/polymer-analyzer/subscription","commits_url":"https://api.github.com/repos/Polymer/polymer-analyzer/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/polymer-analyzer/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polymer/polymer-analyzer/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/polymer-analyzer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/polymer-analyzer/merges","archive_url":"https://api.github.com/repos/Polymer/polymer-analyzer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/polymer-analyzer/downloads","issues_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/polymer-analyzer/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/polymer-analyzer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/polymer-analyzer/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/polymer-analyzer/releases{/id}","deployments_url":"https://api.github.com/repos/Polymer/polymer-analyzer/deployments","created_at":"2015-01-29T18:56:38Z","updated_at":"2017-01-24T20:54:49Z","pushed_at":"2017-01-30T06:10:01Z","git_url":"git://github.com/Polymer/polymer-analyzer.git","ssh_url":"git@github.com:Polymer/polymer-analyzer.git","clone_url":"https://github.com/Polymer/polymer-analyzer.git","svn_url":"https://github.com/Polymer/polymer-analyzer","homepage":"","size":26159,"stargazers_count":119,"watchers_count":119,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":46,"mirror_url":null,"open_issues_count":61,"forks":46,"open_issues":61,"watchers":119,"default_branch":"master"}},"base":{"label":"Polymer:typescript","ref":"typescript","sha":"5de8484e0fb76eb5b0eb4e1c66fdc12e1ce652a8","user":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":30035812,"name":"polymer-analyzer","full_name":"Polymer/polymer-analyzer","owner":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polymer/polymer-analyzer","description":"A static analysis framework for web applications.","fork":false,"url":"https://api.github.com/repos/Polymer/polymer-analyzer","forks_url":"https://api.github.com/repos/Polymer/polymer-analyzer/forks","keys_url":"https://api.github.com/repos/Polymer/polymer-analyzer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/polymer-analyzer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/polymer-analyzer/teams","hooks_url":"https://api.github.com/repos/Polymer/polymer-analyzer/hooks","issue_events_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/polymer-analyzer/events","assignees_url":"https://api.github.com/repos/Polymer/polymer-analyzer/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/polymer-analyzer/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/polymer-analyzer/tags","blobs_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/polymer-analyzer/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/polymer-analyzer/languages","stargazers_url":"https://api.github.com/repos/Polymer/polymer-analyzer/stargazers","contributors_url":"https://api.github.com/repos/Polymer/polymer-analyzer/contributors","subscribers_url":"https://api.github.com/repos/Polymer/polymer-analyzer/subscribers","subscription_url":"https://api.github.com/repos/Polymer/polymer-analyzer/subscription","commits_url":"https://api.github.com/repos/Polymer/polymer-analyzer/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/polymer-analyzer/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/polymer-analyzer/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polymer/polymer-analyzer/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/polymer-analyzer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/polymer-analyzer/merges","archive_url":"https://api.github.com/repos/Polymer/polymer-analyzer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/polymer-analyzer/downloads","issues_url":"https://api.github.com/repos/Polymer/polymer-analyzer/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/polymer-analyzer/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/polymer-analyzer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/polymer-analyzer/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/polymer-analyzer/releases{/id}","deployments_url":"https://api.github.com/repos/Polymer/polymer-analyzer/deployments","created_at":"2015-01-29T18:56:38Z","updated_at":"2017-01-24T20:54:49Z","pushed_at":"2017-01-30T06:10:01Z","git_url":"git://github.com/Polymer/polymer-analyzer.git","ssh_url":"git@github.com:Polymer/polymer-analyzer.git","clone_url":"https://github.com/Polymer/polymer-analyzer.git","svn_url":"https://github.com/Polymer/polymer-analyzer","homepage":"","size":26159,"stargazers_count":119,"watchers_count":119,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":46,"mirror_url":null,"open_issues_count":61,"forks":46,"open_issues":61,"watchers":119,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437"},"html":{"href":"https://github.com/Polymer/polymer-analyzer/pull/437"},"issue":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/437"},"comments":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/issues/437/comments"},"review_comments":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437/comments"},"review_comment":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/pulls/437/commits"},"statuses":{"href":"https://api.github.com/repos/Polymer/polymer-analyzer/statuses/5203a37fa58b70e0ee7edc2208d244a3f6f1ec5a"}}}}
{"actor":{"display_login":"rictic"}}