Skip to content

tsc vs tsgo: inference mismatch of parameter in passed callback #1727

@AviVahl

Description

@AviVahl

Steps to reproduce

mkdir tsgo-vs-tsc
cd tsgo-vs-tsc
npm init -y
npm pkg set type=module
npm i typescript @typescript/native-preview css-tree @types/css-tree -D
npx tsc --init --module nodenext --moduleResolution nodenext
printf "import { parse, walk } from 'css-tree';\nconst declarationsText = '...';\nconst ast = parse(declarationsText, { context: 'declarationList', positions: true });\n\nwalk(ast, {\n    visit: 'Declaration',\n    enter(node) {\n        console.log(node);\n    },\n});" > main.ts
npx tsc --noEmit
npx tsgo --noEmit

In case your terminal doesn't support printf, the contents of main.ts:

import { parse, walk } from 'css-tree';
const declarationsText = '...';
const ast = parse(declarationsText, { context: 'declarationList', positions: true });

walk(ast, {
    visit: 'Declaration',
    enter(node) {
        console.log(node);
    },
});

Behavior with [email protected]

No type errors. node is inferred as Declaration.

Behavior with tsgo

main.ts:7:11 - error TS7006: Parameter 'node' implicitly has an 'any' type.

7     enter(node) {
            ~~~~


Found 1 error in main.ts:7

Metadata

Metadata

Assignees

Labels

Domain: Type CheckingRelated to type checking, grammar checkingbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions