GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — API: getTypeAtLocation returns the error type for an identifier inside a type reference · Issue #65686 · microsoft/TypeScript Backlog Backlog Copy link DescriptionTypeScript VersionThe tested TypeScript version is 7.1.0-dev.20261126.1. 7.1.0-beta gives the same result. The expected result is from 6.0.3. User GoalThe user maintains a documentation extractor that walks the AST and asks the checker for the type of each node. I compared the 6.0 checker API with the 7.1 Setup and Action
interface Foo { a: number } declare namespace NS { interface Bar { b: string } } export declare let x: Foo; export declare let y: NS.Bar;
{ "compilerOptions": { "strict": true, "noEmit": true }, "include": ["src"] }
import path from 'node:path'; import { API } from 'typescript/sync'; import { isIdentifier, isQualifiedName, isTypeReferenceNode } from 'typescript/ast/is'; const config = path.resolve('tsconfig.json'); const api = new API({ cwd: process.cwd() }); const snapshot = api.createSnapshot({ openProjects: [config] }); const { program, checker } = snapshot.getConfiguredProject(config); const sourceFile = program.getSourceFile(path.resolve('src/index.ts')); const text = (node) => sourceFile.text.slice(node.pos, node.end).trim(); function visit(node) { const isTypeName = isIdentifier(node) && (isTypeReferenceNode(node.parent) || (isQualifiedName(node.parent) && node.parent.right === node)); if (isTypeReferenceNode(node) || isTypeName) { const type = checker.getTypeAtLocation(node); console.log(`${isTypeName ? 'Identifier ' : 'TypeReference'} ${text(node).padEnd(6)} -> ${checker.typeToString(type)}`); } node.forEachChild(visit); } sourceFile.forEachChild(visit); snapshot.dispose(); api.close(); Expected and Actual BehaviorWhat actually happened: What I expected: the declared type of the referenced symbol, as in 6.0.3: Agent InfoClaude Code 2.1.198 + Claude Opus 5.5 + Skill Version 1.0 ActivityMetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |