Skip to content

does not exist on type 'typeof global' #27057

Closed

Description

@joma74

TypeScript Version: 3.1.0-dev.20180912

Search Terms:
js ts global nodejs

Code
See Playground Link

Expected behavior:
No tsc error

Actual behavior:
tsglobalissue-2018-09-12_21 15 19

[ts] Property 'getErrorAsString' does not exist on type 'typeof global'.

A second - possibly related issue - is that the declaration of clazz1bGlobalVar: clazz1b in ./types/node-global.d.ts is infered to (property) NodeJS.Global.clazz1bGlobalVar: any

A third - possibly related issue - is that if you alter the declaration of clazz1bGlobalVar: clazz1b in ./types/node-global.d.ts to clazz1bGlobalVar: number, it is infered correctly in this file as (property) NodeJS.Global.clazz1bGlobalVar: number. But in e.g. index.js, you can assign just a value of any type to that, e.g. global.clazz1bGlobalVar= "clazz1bInstance". And on hover (property) global.clazz1bGlobalVar: string is shown.

Playground Link:

git clone https://github.com/joma74/ts-in-js-1.git
git checkout ts-issue-global-demo
cd ts-in-js-1
yarn install
yarn tsc_validate_watch

Open index.js and change as shown in video

Related Issues:
None found

Activity

  1. added
    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this feature
    checkJsRelates to checking JavaScript using TypeScript
    SuggestionAn idea for TypeScript
    and removed
    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this feature
    on Sep 12, 2018
  2. DanielRosenwasser commented on Sep 12, 2018

    @DanielRosenwasser
    Member

    Right now you'll need to augment the type of the global object in Node, though I suspect this is a relatively common thing.

  3. joma74 commented on Sep 13, 2018

    @joma74
    Author

    This should already be addressed by types/node-global.d.ts in the playground link. If not, sorry, i could not follow your advice.

  4. brendankenny commented on Sep 18, 2018

    @brendankenny
    Contributor

    I believe this was fixed by #26918 (like #27099 was) and should be good to go with typescript@next

  5. joma74 commented on Sep 19, 2018

    @joma74
    Author

    Brendan Kenny (@brendankenny) Thanks for the heads-up!
    Confirm that this is fixed in 3.1.0-dev.20180919

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScriptcheckJsRelates to checking JavaScript using TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions