typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
109 stars 51 forks source link

VSCode completion after disabling the builtin typescript extension #506

Open flashios09 opened 1 year ago

flashios09 commented 1 year ago

Hi,

For a reason that i ignore, after disabling the builtin typescript extension, VSCode can't recognize the import paths and stop giving me suggestions/auto imports !

BEFORE

Import suggestion:

image

Service register suggestion:

image

Class/Interface suggestion:

image

AFTER

Import suggestion:

image

Service register suggestion:

image

Class/Interface suggestion:

image

I have enabled the tracking with verbose mode, trying to compare the default Typescript language server with Glint language server.

This is the output after typing import hb:

Typescript language server:

[Trace  - 17:49:42.226] <semantic> Sending request: quickinfo (164). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
    "line": 6,
    "offset": 9
}
[Trace  - 17:49:42.233] <semantic> Response received: quickinfo (164). Request took 7 ms. Success: true 
Result: {
    "kind": "alias",
    "kindModifiers": "",
    "start": {
        "line": 6,
        "offset": 8
    },
    "end": {
        "line": 6,
        "offset": 9
    },
    "displayString": "import h",
    "documentation": [],
    "tags": []
}
[Trace  - 17:49:44.792] <syntax> Sending request: updateOpen (49). Response expected: yes. Current queue length: 0
Arguments: {
    "changedFiles": [
        {
            "fileName": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
            "textChanges": [
                {
                    "newText": "b",
                    "start": {
                        "line": 6,
                        "offset": 9
                    },
                    "end": {
                        "line": 6,
                        "offset": 9
                    }
                }
            ]
        }
    ],
    "closedFiles": [],
    "openFiles": []
}
[Trace  - 17:49:44.792] <semantic> Sending request: updateOpen (165). Response expected: yes. Current queue length: 0
Arguments: {
    "changedFiles": [
        {
            "fileName": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
            "textChanges": [
                {
                    "newText": "b",
                    "start": {
                        "line": 6,
                        "offset": 9
                    },
                    "end": {
                        "line": 6,
                        "offset": 9
                    }
                }
            ]
        }
    ],
    "closedFiles": [],
    "openFiles": []
}
[Trace  - 17:49:44.792] <semantic> Response received: updateOpen (165). Request took 0 ms. Success: true 
Result: true
[Trace  - 17:49:44.793] <semantic> Sending request: documentHighlights (166). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
    "line": 6,
    "offset": 10,
    "filesToSearch": [
        "/PATH_TO_EMBER_APP/app/components/navigation/component.ts"
    ]
}
[Trace  - 17:49:44.793] <syntax> Response received: updateOpen (49). Request took 1 ms. Success: true 
Result: true
[Trace  - 17:49:44.805] <semantic> Response received: documentHighlights (166). Request took 13 ms. Success: true 
Result: [
    {
        "file": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "highlightSpans": [
            {
                "start": {
                    "line": 6,
                    "offset": 8
                },
                "end": {
                    "line": 6,
                    "offset": 10
                },
                "contextStart": {
                    "line": 6,
                    "offset": 1
                },
                "contextEnd": {
                    "line": 6,
                    "offset": 10
                },
                "kind": "writtenReference"
            }
        ]
    }
]
[Trace  - 17:49:44.808] <semantic> Sending request: completionInfo (167). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
    "line": 6,
    "offset": 10,
    "includeExternalModuleExports": true,
    "includeInsertTextCompletions": true,
    "triggerKind": 1
}
[Trace  - 17:49:44.818] <semantic> Response received: completionInfo (167). Request took 10 ms. Success: true 
Result: {
    "flags": 3,
    "isGlobalCompletion": false,
    "isMemberCompletion": false,
    "isNewIdentifierLocation": true,
    "optionalReplacementSpan": {
        "start": {
            "line": 6,
            "offset": 8
        },
        "end": {
            "line": 6,
            "offset": 10
        }
    },
    "entries": [
        {
            "name": "hasEmberVersion",
            "kind": "alias",
            "kindModifiers": "declare,export",
            "sortText": "11",
            "insertText": "import { hasEmberVersion$1 } from \"@ember/test-helpers\";",
            "replacementSpan": {
                "start": {
                    "line": 6,
                    "offset": 1
                },
                "end": {
                    "line": 6,
                    "offset": 10
                }
            },
            "isSnippet": true,
            "source": "@ember/test-helpers",
            "sourceDisplay": [
                {
                    "text": "@ember/test-helpers",
                    "kind": "text"
                }
            ],
            "isImportStatementCompletion": true,
            "data": {
                "exportName": "hasEmberVersion",
                "moduleSpecifier": "@ember/test-helpers",
                "fileName": "/PATH_TO_EMBER_APP/node_modules/@ember/test-helpers/public-types/@ember/test-helpers/index.d.ts"
            }
        },
        {
            "name": "hbs",
            "kind": "function",
            "kindModifiers": "export,declare",
            "sortText": "11",
            "insertText": "import { hbs$1 } from \"ember-cli-htmlbars\";",
            "replacementSpan": {
                "start": {
                    "line": 6,
                    "offset": 1
                },
                "end": {
                    "line": 6,
                    "offset": 10
                }
            },
            "isSnippet": true,
            "source": "ember-cli-htmlbars",
            "sourceDisplay": [
                {
                    "text": "ember-cli-htmlbars",
                    "kind": "text"
                }
            ],
            "isImportStatementCompletion": true,
            "data": {
                "exportName": "hbs",
                "moduleSpecifier": "ember-cli-htmlbars",
                "fileName": "/PATH_TO_EMBER_APP/node_modules/ember-cli-htmlbars/lib/index.d.ts"
            }
        },
        {
            "name": "HTMLElementContentEditable",
            "kind": "interface",
            "kindModifiers": "export,declare",
            "sortText": "11",
            "insertText": "import { HTMLElementContentEditable$1 } from \"@ember/test-helpers/dom/-target\";",
            "replacementSpan": {
                "start": {
                    "line": 6,
                    "offset": 1
                },
                "end": {
                    "line": 6,
                    "offset": 10
                }
            },
            "isSnippet": true,
            "source": "@ember/test-helpers/dom/-target",
            "sourceDisplay": [
                {
                    "text": "@ember/test-helpers/dom/-target",
                    "kind": "text"
                }
            ],
            "isImportStatementCompletion": true,
            "data": {
                "exportName": "HTMLElementContentEditable",
                "moduleSpecifier": "@ember/test-helpers/dom/-target",
                "fileName": "/PATH_TO_EMBER_APP/node_modules/@ember/test-helpers/public-types/@ember/test-helpers/dom/-target.d.ts"
            }
        },
        {
            "name": "type",
            "kind": "keyword",
            "kindModifiers": "",
            "sortText": "15"
        }
    ]
}
[Trace  - 17:49:44.871] <semantic> Sending request: completionEntryDetails (168). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
    "line": 6,
    "offset": 10,
    "entryNames": [
        {
            "name": "hbs",
            "source": "ember-cli-htmlbars",
            "data": {
                "exportName": "hbs",
                "moduleSpecifier": "ember-cli-htmlbars",
                "fileName": "/PATH_TO_EMBER_APP/node_modules/ember-cli-htmlbars/lib/index.d.ts"
            }
        }
    ]
}
[Trace  - 17:49:44.882] <semantic> Response received: completionEntryDetails (168). Request took 11 ms. Success: true 
Result: [
    {
        "name": "hbs",
        "kindModifiers": "export,declare",
        "kind": "function",
        "displayParts": [
            {
                "text": "function",
                "kind": "keyword"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "hbs",
                "kind": "functionName"
            },
            {
                "text": "(",
                "kind": "punctuation"
            },
            {
                "text": "template",
                "kind": "parameterName"
            },
            {
                "text": ":",
                "kind": "punctuation"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "string",
                "kind": "keyword"
            },
            {
                "text": ",",
                "kind": "punctuation"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "options",
                "kind": "parameterName"
            },
            {
                "text": "?",
                "kind": "punctuation"
            },
            {
                "text": ":",
                "kind": "punctuation"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "PrecompileOptions",
                "kind": "interfaceName"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "|",
                "kind": "punctuation"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "undefined",
                "kind": "keyword"
            },
            {
                "text": ")",
                "kind": "punctuation"
            },
            {
                "text": ":",
                "kind": "punctuation"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "TemplateFactory",
                "kind": "interfaceName"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "(",
                "kind": "punctuation"
            },
            {
                "text": "+",
                "kind": "operator"
            },
            {
                "text": "1",
                "kind": "numericLiteral"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "overload",
                "kind": "text"
            },
            {
                "text": ")",
                "kind": "punctuation"
            }
        ],
        "documentation": [
            {
                "text": "A helper for rendering components.",
                "kind": "text"
            }
        ],
        "tags": [
            {
                "name": "param",
                "text": [
                    {
                        "text": "tagged",
                        "kind": "parameterName"
                    },
                    {
                        "text": " ",
                        "kind": "space"
                    },
                    {
                        "text": "The template to render.\n\n## Usage\n\n### With tagged template\n\n```ts\nimport { module, test } from 'qunit';\nimport { setupRenderingTest } from 'ember-qunit';\nimport { render } from '@ember/test-helpers';\nimport { hbs } from 'ember-cli-htmlbars';\n\nmodule('demonstrate hbs usage', function(hooks) {\nsetupRenderingTest(hooks);\n\ntest('you can render things', function(assert) {\nawait render(hbs`<TestingComponents @isCool={{true}} />`);\nassert.ok(true);\n});\n});\n```\n\n## With string and options\n\n```ts\nimport Component from '@glimmer/component';\nimport { setComponentTemplate } from '@ember/component';\nimport { hbs } from 'ember-cli-htmlbars';\n\nclass Hello extends Component {\ngreeting = 'hello world';\n}\n\nsetComponentTemplate(\nhbs('<p>{{this.greeting}}</p>', { moduleName: 'hello.hbs' }),\nMyComponent\n);\n```",
                        "kind": "text"
                    }
                ]
            }
        ],
        "source": [
            {
                "text": "ember-cli-htmlbars",
                "kind": "text"
            }
        ],
        "sourceDisplay": [
            {
                "text": "ember-cli-htmlbars",
                "kind": "text"
            }
        ]
    }
]

Glint language server:

[Trace - 7:06:34 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "version": 77
    },
    "contentChanges": [
        {
            "text": "import \n// import AppComponent from 'hotelas/components/app-component';\n// import IEmberSimpleAuthSessionService from 'hotelas/services/ember-simple-auth-session';\n// import { action } from '@ember/object';\n// import { service } from '@ember/service';\n// import CurrentUserService from 'hotelas/services/current-user';\n\n// interface NavigationComponentArgs {}\n\n// export default class NavigationComponent extends AppComponent<NavigationComponentArgs> {\n//   @service('ember-simple-auth-session')\n//   declare session: IEmberSimpleAuthSessionService;\n\n//   @service('current-user')\n//   declare currentUser: CurrentUserService;\n\n//   @service('store')\n//   declare store: IFron\n\n//   @action\n//   logout() {\n//     this.session.invalidate();\n//   }\n// }\n"
        }
    ]
}

[Trace - 7:06:35 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
    "diagnostics": []
}

[Trace - 7:06:37 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "version": 78
    },
    "contentChanges": [
        {
            "text": "import h\n// import AppComponent from 'hotelas/components/app-component';\n// import IEmberSimpleAuthSessionService from 'hotelas/services/ember-simple-auth-session';\n// import { action } from '@ember/object';\n// import { service } from '@ember/service';\n// import CurrentUserService from 'hotelas/services/current-user';\n\n// interface NavigationComponentArgs {}\n\n// export default class NavigationComponent extends AppComponent<NavigationComponentArgs> {\n//   @service('ember-simple-auth-session')\n//   declare session: IEmberSimpleAuthSessionService;\n\n//   @service('current-user')\n//   declare currentUser: CurrentUserService;\n\n//   @service('store')\n//   declare store: IFron\n\n//   @action\n//   logout() {\n//     this.session.invalidate();\n//   }\n// }\n"
        }
    ]
}

[Trace - 7:06:37 PM] Sending request 'textDocument/completion - (59)'.
Params: {
    "textDocument": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts"
    },
    "position": {
        "line": 0,
        "character": 8
    },
    "context": {
        "triggerKind": 1
    }
}

[Trace - 7:06:37 PM] Received response 'textDocument/completion - (59)' in 38ms.
Result: [
    {
        "label": "h",
        "kind": 6,
        "data": {
            "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
            "transformedFileName": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
            "transformedOffset": 8
        }
    }, 
    ...
]

[Trace - 7:06:37 PM] Sending request 'completionItem/resolve - (60)'.
Params: {
    "label": "h",
    "insertTextFormat": 1,
    "kind": 6,
    "data": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedFileName": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedOffset": 8
    }
}

[Trace - 7:06:37 PM] Received response 'completionItem/resolve - (60)' in 7ms.
Result: {
    "label": "h",
    "insertTextFormat": 1,
    "kind": 6,
    "data": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedFileName": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedOffset": 8
    },
    "detail": "import h",
    "documentation": {
        "kind": "markdown",
        "value": ""
    }
}

[Trace - 7:06:37 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "version": 79
    },
    "contentChanges": [
        {
            "text": "import hb\n// import AppComponent from 'hotelas/components/app-component';\n// import IEmberSimpleAuthSessionService from 'hotelas/services/ember-simple-auth-session';\n// import { action } from '@ember/object';\n// import { service } from '@ember/service';\n// import CurrentUserService from 'hotelas/services/current-user';\n\n// interface NavigationComponentArgs {}\n\n// export default class NavigationComponent extends AppComponent<NavigationComponentArgs> {\n//   @service('ember-simple-auth-session')\n//   declare session: IEmberSimpleAuthSessionService;\n\n//   @service('current-user')\n//   declare currentUser: CurrentUserService;\n\n//   @service('store')\n//   declare store: IFron\n\n//   @action\n//   logout() {\n//     this.session.invalidate();\n//   }\n// }\n"
        }
    ]
}

[Trace - 7:06:37 PM] Sending request 'completionItem/resolve - (61)'.
Params: {
    "label": "HTMLBaseElement",
    "insertTextFormat": 1,
    "kind": 6,
    "data": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedFileName": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedOffset": 8
    }
}

[Trace - 7:06:37 PM] Received response 'completionItem/resolve - (61)' in 24ms.
Result: {
    "label": "HTMLBaseElement",
    "insertTextFormat": 1,
    "kind": 6,
    "data": {
        "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedFileName": "/PATH_TO_EMBER_APP/app/components/navigation/component.ts",
        "transformedOffset": 8
    },
    "detail": "interface HTMLBaseElement\nvar HTMLBaseElement: {\n    new (): HTMLBaseElement;\n    prototype: HTMLBaseElement;\n}",
    "documentation": {
        "kind": "markdown",
        "value": "Contains the base URI for a document. This object inherits all of the properties and methods as described in the HTMLElement interface."
    }
}

[Trace - 7:06:37 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
    "diagnostics": [
        {
            "severity": 1,
            "message": "Import declaration 'hb' is using private name ''.",
            "source": "glint:ts(4000)",
            "tags": [],
            "range": {
                "start": {
                    "line": 0,
                    "character": 9
                },
                "end": {
                    "line": 0,
                    "character": 9
                }
            }
        }
    ]
}

[Trace - 7:06:40 PM] Sending notification '$/setTrace'.
Params: {
    "value": "verbose"
}

[Trace - 7:06:40 PM] Sending notification '$/setTrace'.
flashios09 commented 1 year ago

I'm not sure but i think the issue is here:

[Trace - 7:06:37 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///PATH_TO_EMBER_APP/app/components/navigation/component.ts",
    "diagnostics": [
        {
            "severity": 1,
            "message": "Import declaration 'hb' is using private name ''.",
            "source": "glint:ts(4000)",
            "tags": [],
            "range": {
                "start": {
                    "line": 0,
                    "character": 9
                },
                "end": {
                    "line": 0,
                    "character": 9
                }
            }
        }
    ]
}

After typing import hb, the message is "Import declaration 'hb' is using private name ''." !

machty commented 8 months ago

dup of #130

NullVoxPopuli commented 7 months ago

@flashios09 if you upgrade to 1.3, do you get your completions back?

flashios09 commented 7 months ago

@flashios09 if you upgrade to 1.3, do you get your completions back?

@NullVoxPopuli Sorry for the delay :(

I have upgraded to 1.3, it will detect the imports but not triggering the completion, e.g.: image If i select service, it will just complete the word, from servi to service: image Expecting import { service } from '@ember/service' but getting import service !

The stacktrace BEFORE choosing the service import:

[Trace - 8:04:27 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts",
        "version": 35
    },
    "contentChanges": [
        {
            "text": "import Route from '@ember/routing/route';\nimport servi\n\nexport default class UsersRoute extends Route {\n  model() {\n  }\n}\n"
        }
    ]
}

[Trace - 8:04:27 PM] Sending request 'textDocument/codeAction - (36)'.
Params: {
    "textDocument": {
        "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts"
    },
    "range": {
        "start": {
            "line": 1,
            "character": 12
        },
        "end": {
            "line": 1,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}

[Trace - 8:04:27 PM] Received response 'textDocument/codeAction - (36)' in 2ms.
Result: []

[Trace - 8:04:27 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts",
    "diagnostics": [
        {
            "source": "glint",
            "code": 1005,
            "severity": 1,
            "message": "'=' expected.",
            "tags": [],
            "range": {
                "start": {
                    "line": 3,
                    "character": 0
                },
                "end": {
                    "line": 3,
                    "character": 6
                }
            }
        }
    ]
}

[Trace - 8:04:27 PM] Sending request 'textDocument/codeAction - (37)'.
Params: {
    "textDocument": {
        "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts"
    },
    "range": {
        "start": {
            "line": 1,
            "character": 12
        },
        "end": {
            "line": 1,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}

[Trace - 8:04:27 PM] Received response 'textDocument/codeAction - (37)' in 2ms.
Result: []

The stacktrace AFTER choosing the service import:

[Trace - 8:07:03 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts",
        "version": 39
    },
    "contentChanges": [
        {
            "text": "import Route from '@ember/routing/route';\nimport service\n\nexport default class UsersRoute extends Route {\n  model() {\n  }\n}\n"
        }
    ]
}

[Trace - 8:07:04 PM] Sending request 'textDocument/codeAction - (46)'.
Params: {
    "textDocument": {
        "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts"
    },
    "range": {
        "start": {
            "line": 1,
            "character": 14
        },
        "end": {
            "line": 1,
            "character": 14
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}

[Trace - 8:07:04 PM] Received response 'textDocument/codeAction - (46)' in 1ms.
Result: []

[Trace - 8:07:04 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts",
    "diagnostics": [
        {
            "source": "glint",
            "code": 1005,
            "severity": 1,
            "message": "'=' expected.",
            "tags": [],
            "range": {
                "start": {
                    "line": 3,
                    "character": 0
                },
                "end": {
                    "line": 3,
                    "character": 6
                }
            }
        }
    ]
}

[Trace - 8:07:04 PM] Sending request 'textDocument/codeAction - (47)'.
Params: {
    "textDocument": {
        "uri": "file:///Volumes/Data/Sites/ember4121/app/routes/users.ts"
    },
    "range": {
        "start": {
            "line": 1,
            "character": 14
        },
        "end": {
            "line": 1,
            "character": 14
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}

[Trace - 8:07:04 PM] Received response 'textDocument/codeAction - (47)' in 2ms.
Result: []