Comments (5)
The new option ignoreFunctions
has solved my problem. Thanks so much
from typescript-is.
Hi @SteMab
There are two things going on that are causing the issue:
-
When you write
type MappedType = { [P in keyof MyClass]: MyClass[P]; }
, TypeScript does not keepmethod
as an actual method. Instead, it becomes a regular object property with a function type. You can see this if you inspect the typeMappedType
, it will have the propertymethod
as a function:method: () => string
. -
Because of this,
ignoreMethods
will not be checked to decide to ignore this property.typescript-is
is now working with a regular function, and because these are not supported, its behavior is undefined.
To solve this:
-
I can add a new option
ignoreFunctions
with similar behavior asignoreMethods
but will work for any function. -
You can avoid using
assertType
on classes/functions/methods. Since you have a class instance, why not useinstanceof
?
from typescript-is.
@woutervh- Thank you for your kind reply which clarified the point.
I can't use instanceof because I'm writing an http firebase function and the object to check was been serialized.
An option ignoreFunctions would be useful, in my opinion (but I'm not familiar with typescript and prototype-based programming).
from typescript-is.
Hi @SteMab
I've added the option ignoreFunctions
:
https://github.com/woutervh-/typescript-is/releases/tag/v0.14.3
https://github.com/woutervh-/typescript-is#options
Let me know if this helps :)
from typescript-is.
Found this from the link in the error message and want to leave a note that ignoreFunctions
is deprecated and you can now declare functionBehavior: "basic"
instead.
from typescript-is.
Related Issues (20)
- Feature Request: Shortcut to simplify `const v = func(); is<type>(v) ? v : default` HOT 1
- Fix intersections with primitives to add support for branded/flavored types HOT 1
- Intersection disables `disallowSuperfluousProperties` all the way down
- Non-deterministic code generated HOT 1
- Support typeof on object types
- Parsing fails when target & aliasTypeArguments are at different levels HOT 1
- Investigation of Unbound Type Parameters
- typescript-is introduces "typescript" dependency into production environment
- TypeError: Cannot read property 'text' of undefined
- Bug: A missing key and a key with a value of undefined are not considered the same
- Fail to check Enum in Record HOT 9
- Have you plan to support Deno? HOT 2
- use instantiation expressions in typescript 4.7
- Make generated code smaller by putting reusable strings to constants or functions HOT 1
- feature request: set custom error class in AssertType
- Thoughts on extending createAssertType() HOT 1
- Incompatible with TypeScript 4.8 HOT 2
- What about re-export `typia` for maintenance? HOT 1
- ttypescript not support TS@5
- Deprecation message and recommends to use `typia` instead HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-is.