Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing types when resolving intersection (string | null) #1580

Open
TomChv opened this issue Oct 17, 2024 · 0 comments
Open

Missing types when resolving intersection (string | null) #1580

TomChv opened this issue Oct 17, 2024 · 0 comments

Comments

@TomChv
Copy link

TomChv commented Oct 17, 2024

Describe the bug

Version: 24.0.0

I've hit this issue when I was introspecting some intersection type and couldn't actually resolve to the correct type.

For example: string | null only returns me string.

Here's an example of what ts-morph returns and the comparison with the actual TS compiler API:

// TS Compiler API
type: [ 'string | null' ]

// ts-morph
this.node.getType().getText(): string
testWithAllCheckerFunction: {
  isAnonymous: false,
  isAny: false,
  isArray: false,
  isBoolean: false,
  isBooleanLiteral: false,
  isClass: false,
  isClassOrInterface: false,
  isEnum: false,
  isEnumLiteral: false,
  isInterface: false,
  isIntersection: false,
  isLiteral: false,
  isNull: false,
  isNumber: false,
  isNumberLiteral: false,
  isObject: false,
  isString: true,
  isStringLiteral: false,
  isTemplateLiteral: false,
  isTuple: false,
  isUndefined: false,
  isUnion: false,
  isUnionOrIntersection: false,
  isUnknown: false
}

To Reproduce

I think it's a pretty much understandable issue without a repro, let me know if you absolutely need one.

Expected behavior

I thought ts-morph would at least returns true to isIntersection, I know resolving the value can be very complex but I don't understand why some checker actually return false except isString.

Let me know if you need more context/information. Happy to help also if you give me precise hints :)

@TomChv TomChv changed the title Missing types when using intersection (string | null) Missing types when resolving intersection (string | null) Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant